import React from 'react'
import ReactDOM from 'react-dom/client'
import {
  Route,
  RouterProvider,
  createBrowserRouter,
  createRoutesFromElements,
} from 'react-router-dom'
import './index.scss'
import AboutPage, { loader as aboutLoader } from '@routes/about'
import ConstsPage, { loader as constLoader } from '@routes/consts'
import App from '@/App'

const router = createBrowserRouter(
  createRoutesFromElements(
    <Route path="/" element={<App />}>
      <Route path="/about" element={<AboutPage />} loader={aboutLoader} />
      <Route path="/consts" element={<ConstsPage />} loader={constLoader} />
    </Route>,
  ),
)

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>,
)
